let passenerData, weixinId

try {
  passenerData = JSON.parse(sessionStorage.getItem('passenerInfoData')) || {}
  weixinId = JSON.parse(sessionStorage.getItem('getWxUserDataId')) || {}
} catch (error) {
  passenerData = {}
  weixinId = {}
}

// 状态管理
const state = {
  passener: passenerData,
  wxData: weixinId // 登录时微信的数据
}

const actions = {
  setMyselfIofo: ({commit, state}, res) => {
    commit('getMyselfInfo', res)
  },
  setWxUserData: ({commit, state}, res) => {
    commit('getWxUserData', res)
  }
}

const mutations = {
  getMyselfInfo: (state, res) => {
    state.passener = res
    console.log(res)
    sessionStorage.setItem('passenerInfoData', res)
  },
  getWxUserData: (state, res) => {
    state.wxData = res
    sessionStorage.setItem('getWxUserDataId', JSON.stringify(state.wxData))
  }
}

export default {
  namespaced: true,
  state,
  actions,
  mutations
}
